<?php

declare(strict_types=1);

namespace app\user\controller;

use app\BaseController;
use app\CheckTokenController;
use app\model\User;

class Index extends BaseController
{
    public function index()
    {
        return '您好！这是一个[user]示例应用';
    }
    public function find()
    {
        $page = $this->request->param('page');
        $DBUser = new User();
        $info = $DBUser->page($page, 11)->select();
        $count = $DBUser->count();
        return result(['sub' => $info, 'count' => $count]);
    }
    public function delete()
    {
        $id = $this->request->param('id');
        $DBUser = new User();
        $info = $DBUser->where('id', $id)->find()->delete();
        return result($info);
    }
    public function add()
    {
        $params = $this->request->param();
        $DBUser = new User();
        $info = $DBUser->save($params);
        return result($info);
    }
}
